package com.udf.flink.scala;

import org.apache.flink.api.common.typeinfo.TypeInformation;
import org.apache.flink.api.common.typeinfo.Types;
import org.apache.flink.api.java.typeutils.RowTypeInfo;
import org.apache.flink.table.functions.TableFunction;
import org.apache.flink.types.Row;
import static org.apache.flink.table.api.Expressions.*;
import org.apache.flink.table.api.*;

/**
 * @author tieyi  2019/12/17 12:10
 * @version 1.0.0
 * @Description: No Description
 * @package PACKAGE_NAME
 * @file Flink_UDF_Demo
 */
public class MyUDTF_Table extends TableFunction<Row> {
//    public void eval(String str) {
//        for (String s : str.split(" ")) {
//            // use collect(...) to emit a row
//            collect(Row.of(s, s.length()));
//        }
//    }
    public void eval(String str) {
        String[] split = str.split(",");
        Row row = new Row(split.length);
        for (int i = 0; i < split.length; i++) {
            row.setField(i,split[i]);
        }
        collect(row);
    }


}
